perm filename TABS.TEX[TEX,DEK] blob
sn#704394 filedate 1983-04-06 generic text, type T, neo UTF8
\let\ifvoid=\ifabsent
\def\loop#1\repeat{\def\body{#1}\iterate}
\def\iterate{\body\let\next=\iterate\else\let\next=\relax\fi\next}
\catcode`(=11 \catcode`)=11
\chardef\()=0 \chardef\(i)=1 \chardef\(ii)=2 \chardef\(z)=255
\newswitch{usebox} \newswitch{cr}
\newbox\tabs \newbox\tabsyet \newbox\tabsdone
\def\settabs{\setbox\tabs=\null \futurelet\next\settab(a)}
\def\settab(a){\ifx\next\+\let\next\settab(b)\else\let\next\settab(c)\fi\next}
\def\settab(b)\+{\useboxfalse\(maketabbox)}
\def\+{\useboxtrue\(maketabbox)}
\def\settab(c)#1\columns{\setcount\(z)=#1 \setdimen\()=\the\hsize
\loop\ifnum\count\(z)>0 \(anothercol)\repeat}
\def\(anothercol){\setdimen\(ii)=\dimen\() \divdimen\(ii) by\count\(z)
\setbox\tabs=\hbox{\hbox to \dimen\(ii){}\unhbox\tabs}%
\advdimen\() by-\dimen\(ii) \advcount\(z) by-\(i)}
\def\(maketabbox)#1\cr{\global\setbox\tabsyet=\copy\tabs
\global\setbox\tabsdone=\null \tabskip=0pt
% \setdimen\()=\the\prevdepth
% \setbox\()=\vbox{\prevdepth=\dimen\()\crfalse
\setbox\()=\vbox{\crfalse \tabskip=0pt
\halign{\tabbox(a)##\tabbox(b)&
\tabbox(a)##\tabbox(b)&
\tabbox(a)##\tabbox(b)&
\tabbox(a)##\tabbox(b)&
\tabbox(a)##\tabbox(b)&
% \tabbox(a)##\tabbox(b)\cr #1\crtrue\cr}%
\tabbox(a)##\tabbox(b)\cr #1\crtrue\cr}}%
% \global\setdimen\(i)=\the\prevdepth}%
\setbox\tabs=\hbox{\unhbox\tabsyet\unhbox\tabsdone}%
% \ifusebox\unvbox\()\prevdepth=\dimen\(i)\fi}
\ifusebox\unvbox\()\lastbox\fi}
\def\cleartabs{\global\setbox\tabsyet=\null\setbox\tabs=\null}
\def\tabbox(a){\setbox\()=\hbox\lb}
\def\tabbox(b){\ifcr\rb % now \box\() holds the column
\else\hss\rb \global\setbox\tabsyet=\hbox{\unhbox\tabsyet
\global\setbox\(i)=\lastbox}% now \box(i) holds its size
\ifvoid\(i)\global\setbox\(i)=\hbox to 1wd\(){}%
\else\setbox\()=\hbox to1wd\(i){\unhbox\()}\fi
\global\setbox\tabsdone=\hbox{\box\(i)\unhbox\tabsdone}\fi
\box\()}
\catcode`(=12 \catcode`)=12
%\tracingall
%\settabs 2\columns
%{Testing:
%\+My&first&test&\cr
%\+& My&second\cr
%\showbox\tabs
%\+&\cleartabs Third&\cr
%\settabs\+My &fourth\showlists\cr
%\showbox\tabs
%}\showbox\tabs